home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / Online / Term / Extras / Source / gtlayout-source.lha / LTP_DefaultEditRoutine.c < prev    next >
C/C++ Source or Header  |  1996-08-22  |  2KB  |  108 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1996 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. ULONG SAVE_DS ASM
  15. LTP_DefaultEditRoutine(REG(a0) struct Hook *Hook,REG(a2) struct SGWork *Work,REG(a1) Msg msg)
  16. {
  17.     struct Hook *Validate;
  18.     LayoutHandle *Handle;
  19.     ObjectNode *Node;
  20.  
  21.     if(!GETOBJECT(Work->Gadget,Node))
  22.         return(TRUE);
  23.  
  24.     switch(msg->MethodID)
  25.     {
  26.         case SGH_KEY:
  27.  
  28.             Handle = Hook->h_Data;
  29.  
  30.             if(Work->IEvent->ie_Code == 0x5F && Handle->HelpHook)
  31.             {
  32.                 Work->Code        = 0x5F;
  33.                 Work->Actions    = (Work->Actions & ~SGA_BEEP) | SGA_END | SGA_USE;
  34.  
  35.                 LTP_AddHistory(Work);
  36.                 break;
  37.             }
  38.  
  39.             if(Work->IEvent->ie_Code == CURSORUP || Work->IEvent->ie_Code == CURSORDOWN)
  40.                 LTP_HandleHistory(Work);
  41.  
  42.             if(Work->EditOp == EO_ENTER)
  43.             {
  44.                 BOOL Activate = TRUE;
  45.  
  46.                 DB(kprintf("enter operation\n"));
  47.  
  48.                 if(Node->Type == STRING_KIND)
  49.                 {
  50.                     if(Node->Special.String.LastGadget)
  51.                         Activate = FALSE;
  52.                 }
  53. #ifndef DO_HEXHOOK
  54.                 else
  55.                 {
  56.                     if(Node->Type == INTEGER_KIND)
  57.                     {
  58.                         if(Node->Special.Integer.LastGadget)
  59.                             Activate = FALSE;
  60.                     }
  61.                 }
  62. #endif
  63.  
  64.                 if(!(Work->IEvent->ie_Qualifier & QUALIFIER_SHIFT))
  65.                 {
  66.                     DB(kprintf("no shift\n"));
  67.  
  68.                     if(Activate && Handle->AutoActivate)
  69.                         Work->Actions |= SGA_NEXTACTIVE;
  70.  
  71.                     if(!(Work->Actions & SGA_NEXTACTIVE))
  72.                         Work->Code = '\r';
  73.                 }
  74.                 else
  75.                     DB(kprintf("has shift\n"));
  76.             }
  77.  
  78.             if(Node->Type == INTEGER_KIND)
  79.                 Validate = Node->Special.Integer.ValidateHook;
  80.             else
  81.                 Validate = Node->Special.String.ValidateHook;
  82.  
  83.             if(Validate)
  84.             {
  85.                 if(!CallHookPkt(Validate,Work,msg))
  86.                 {
  87.                     Work->EditOp    = EO_BADFORMAT;
  88.                     Work->Actions    = SGA_BEEP;
  89.                 }
  90.             }
  91.  
  92.             if(Work->Actions & SGA_END)
  93.                 LTP_AddHistory(Work);
  94.  
  95.             /* Falls through to... */
  96.  
  97.         case SGH_CLICK:
  98.  
  99.             break;
  100.  
  101.         default:
  102.  
  103.             return(FALSE);
  104.     }
  105.  
  106.     return(TRUE);
  107. }
  108.